package com.zhiwei.fast.fragments.dialog

import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import android.view.View
import com.zhiwei.fast.databinding.DialogFragmentSimpleBinding
import com.zhiwei.most.dialog.BaseDialogFragment
import com.zhiwei.most.dialog.DialogLayoutCallback
import com.zhiwei.most.ext.onClickRxView

/**
 * Create by zhiweizhu on 2022/3/4
 */
class SimpleDialogFragment(context: Context, callLayoutCallback: DialogLayoutCallback? = null): BaseDialogFragment<DialogFragmentSimpleBinding>(context) {

    private var mDialogLayoutCallback: DialogLayoutCallback? = null

    init {
        mDialogLayoutCallback = callLayoutCallback
    }

    override fun initData(view: View, savedInstanceState: Bundle?) {

        with(mViewBind){
            dialogCancelBtn.onClickRxView {
                mDialogLayoutCallback?.let {
                    it.onCancel(this@SimpleDialogFragment)
                } ?: dismiss()
            }
            dialogConfirmBtn.onClickRxView {
               mDialogLayoutCallback?.let {
                   it.onDismiss(this@SimpleDialogFragment)
               } ?: dismiss()
            }
        }
    }

    override fun onDialogCancel(dialog: DialogInterface) {

    }

    override fun onDialogDismiss(dialog: DialogInterface) {

    }


}